-
Notifications
You must be signed in to change notification settings - Fork 4
Enhance OSM data I/O and management #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| from argparse import ArgumentParser | ||
| import osmnx as ox | ||
| import networkx as nx |
Check warning
Code scanning / Prospector (reported by Codacy)
Unable to import 'networkx' (import-error) Warning
| from argparse import ArgumentParser | ||
| import osmnx as ox | ||
| import networkx as nx | ||
| import matplotlib.patches as mpatches |
Check warning
Code scanning / Prospector (reported by Codacy)
Unable to import 'matplotlib.patches' (import-error) Warning
| import osmnx as ox | ||
| import networkx as nx | ||
| import matplotlib.patches as mpatches | ||
| import matplotlib.pyplot as plt |
Check warning
Code scanning / Prospector (reported by Codacy)
Unable to import 'matplotlib.pyplot' (import-error) Warning
| G_ALL = ox.graph_from_place(parser.place, network_type="drive") | ||
| print(f"Graph created with {len(G_ALL.nodes)} nodes and {len(G_ALL.edges)} edges.") | ||
|
|
||
| gdf_nodes, gdf_edges = ox.graph_to_gdfs(G_ALL) |
Check warning
Code scanning / Pylint (reported by Codacy)
Constant name "gdf_nodes" doesn't conform to UPPER_CASE naming style Warning
| G_ALL = ox.graph_from_place(parser.place, network_type="drive") | ||
| print(f"Graph created with {len(G_ALL.nodes)} nodes and {len(G_ALL.edges)} edges.") | ||
|
|
||
| gdf_nodes, gdf_edges = ox.graph_to_gdfs(G_ALL) |
Check warning
Code scanning / Pylint (reported by Codacy)
Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style Warning
| # gdf_edges = gdf_edges[~gdf_edges["access"].isin(["no", "private"])] | ||
|
|
||
| # Make a plot to visualize the removed links | ||
| removed_patch = mpatches.Patch(color=RGBA_RED, label="Removed Nodes and Edges") |
Check warning
Code scanning / Pylint (reported by Codacy)
Constant name "removed_patch" doesn't conform to UPPER_CASE naming style Warning
| removed_patch = mpatches.Patch(color=RGBA_RED, label="Removed Nodes and Edges") | ||
|
|
||
| if parser.exclude_motorway: | ||
| gdf_edges = gdf_edges[~gdf_edges["highway"].isin(FLAGS_MOTORWAY)] |
Check warning
Code scanning / Pylint (reported by Codacy)
Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style Warning
| if parser.exclude_motorway: | ||
| gdf_edges = gdf_edges[~gdf_edges["highway"].isin(FLAGS_MOTORWAY)] | ||
| if parser.exclude_residential: | ||
| gdf_edges = gdf_edges[~gdf_edges["highway"].isin(FLAGS_RESIDENTIAL)] |
Check warning
Code scanning / Pylint (reported by Codacy)
Constant name "gdf_edges" doesn't conform to UPPER_CASE naming style Warning
| G.remove_nodes_from(list(nx.isolates(G))) | ||
| print(f"Graph filterded: now it has {len(G.nodes)} nodes and {len(G.edges)} edges.") | ||
|
|
||
| fig, ax = ox.plot_graph( |
Check warning
Code scanning / Pylint (reported by Codacy)
Constant name "fig" doesn't conform to UPPER_CASE naming style Warning
| G.remove_nodes_from(list(nx.isolates(G))) | ||
| print(f"Graph filterded: now it has {len(G.nodes)} nodes and {len(G.edges)} edges.") | ||
|
|
||
| fig, ax = ox.plot_graph( |
Check warning
Code scanning / Pylint (reported by Codacy)
Constant name "ax" doesn't conform to UPPER_CASE naming style Warning
| std::getline(iss, oneway, ';'); | ||
| std::getline(iss, lanes, ';'); | ||
| std::getline(iss, highway, ';'); | ||
| std::getline(iss, maxspeed, ';'); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
|
|
||
| Id streetId = std::stoul(sourceId) + std::stoul(targetId) * m_nodes.size(); | ||
| m_streets.emplace( | ||
| streetId, |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 17.7 rule Note
|
|
||
| Id streetId = std::stoul(sourceId) + std::stoul(targetId) * m_nodes.size(); | ||
| m_streets.emplace( | ||
| streetId, |
Check notice
Code scanning / Cppcheck (reported by Codacy)
Return value of function std::stoul() is not used. Note
| std::stoul(lanes), | ||
| name); | ||
| } | ||
| } else { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| // get number of lines | ||
| std::string line; | ||
| int nNodes{-1}; // -1 because of the header | ||
| while (std::getline(fNodes, line)) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 14.4 rule Note test
| fNodes.close(); | ||
| std::ifstream fEdges{"./data/edges.csv"}; | ||
| int nEdges{-1}; // -1 because of the header | ||
| while (std::getline(fEdges, line)) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 14.4 rule Note test
| // get number of lines | ||
| std::string line; | ||
| int nNodes{-1}; // -1 because of the header | ||
| while (std::getline(fNodes, line)) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 14.4 rule Note test
| fNodes.close(); | ||
| std::ifstream fEdges{"./data/edges_big.csv"}; | ||
| int nEdges{-1}; // -1 because of the header | ||
| while (std::getline(fEdges, line)) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 14.4 rule Note test
No description provided.